package com.santu.edu.supporter.biz.order.helpbuy.pojo.dto;

import com.santu.edu.supporter.biz.order.common.pojo.enums.OrderStatusEnum;
import com.santu.edu.supporter.biz.order.helpbuy.pojo.enums.HelpByProcessType;
import com.santu.edu.supporter.biz.order.helpbuy.pojo.params.HbOrderAddParam;
import com.santu.edu.supporter.biz.order.helpbuy.pojo.params.HbOrderUpdateParam;
import com.santu.edu.supporter.biz.order.helpbuy.pojo.po.HelpBuyOrderPO;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author luoyaoqi
 * @createTime 2024/2/21
 * @description
 */
@Data
@Accessors(chain = true)
public class HelpBuyOrderDTO {

    /**
     * 学校id
     */
    private String schoolId;

    /**
     * 订单号
     */
    private String orderId;

    /**
     * 用户id(发起人)
     */
    private String userId;

    /**
     * 跑路费
     */
    private Long money;

    /**
     * 地址id
     */
    private String buildingsId;

    /**
     * 购买的商品信息
     */
    private String goodInfo;

    /**
     * 商品图片地址
     */
    private String imageUrl;

    /**
     * 是否加急[0:否,1:是]
     */
    private Integer isUrgent;

    /**
     * 打赏金额
     */
    private Long tipping;

    /**
     * 备注信息
     */
    private String remarkInfo;

    /**
     * 送货地址id
     */
    private String addressId;

    /**
     * 订单状态[0:待认领1:进行中2:已完成]
     */
    private OrderStatusEnum orderType;

    /**
     * 进行中的状态[1:商品已购买2:客户已付款]
     */
    private HelpByProcessType processType;

    /**
     * 垫付的钱
     */
    private Long advance;

    /**
     * 验证码
     */
    private String captcha;

    public static HelpBuyOrderDTO createItem(HbOrderAddParam addParam,String orderId) {
        return new HelpBuyOrderDTO()
                .setOrderId(orderId)
                .setUserId(addParam.getUserId())
                .setMoney(addParam.getMoney())
                .setBuildingsId(addParam.getBuildingsId())
                .setGoodInfo(addParam.getGoodInfo())
                .setImageUrl(addParam.getImageUrl())
                .setIsUrgent(addParam.getIsUrgent())
                .setTipping(addParam.getTipping())
                .setRemarkInfo(addParam.getRemarkInfo())
                .setAddressId(addParam.getAddressId())
                .setOrderType(OrderStatusEnum.IN_PROGRESS)
                .setProcessType(HelpByProcessType.PRODUCT_NOT_PURCHASED)
                .setAdvance(0L);
    }


    public static HelpBuyOrderDTO createItem(HbOrderUpdateParam updateParam) {
        return new HelpBuyOrderDTO()
                .setOrderId(updateParam.getOrderId())
                .setAddressId(updateParam.getAddressId());
    }


    public static HelpBuyOrderDTO createItem(HelpBuyOrderPO item) {
        return new HelpBuyOrderDTO()
                .setOrderId(item.getOrderId())
                .setUserId(item.getUserId())
                .setMoney(item.getMoney())
                .setBuildingsId(item.getBuildingsId())
                .setGoodInfo(item.getGoodInfo())
                .setImageUrl(item.getImageUrl())
                .setIsUrgent(item.getIsUrgent())
                .setTipping(item.getTipping())
                .setRemarkInfo(item.getRemarkInfo())
                .setAddressId(item.getAddressId())
                .setOrderType(OrderStatusEnum.convert(item.getOrderType()))
                .setProcessType(HelpByProcessType.convert(item.getProcessType()))
                .setAdvance(item.getAdvance())
                .setSchoolId(item.getSchoolId())
                .setCaptcha(item.getCaptcha());
    }
}
